<!--
 * @Description: 
 * @Author: charles
 * @Date: 2021-05-05 22:02:56
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-01-07 16:21:55
-->
<template>
  <!--1. 容器 -->
  <div ref="left1_container" id="container5" style="height: 95%"></div>
</template>
<script>
//引入折线构造函数
import { Line } from "@antv/g2plot";
import { get } from "../../../utils/request";
import moment from "moment";
export default {
  data() {
    return {
      dataArr: [],
    };
  },
  created() {},
  mounted() {
    this.initData();
  },
  methods: {
    initData() {

      get("/dashboard/pageQueryTodayData", {
        page: 1,
        pageSize: 5,
        device_id: 1,
      }).then((res) => {
        res.data.list.forEach((item) => {
          item.dateTime = moment(item.insert_time).format("HH:mm");
        });
        console.log(444, res);
        console.log(res.data.list);
        this.dataArr = res.data.list;
        this.initChart();
      });
    },
    //创建一个折线图实例对象
    initChart() {
      const line = new Line("container5", {
        data: this.dataArr,
        xField: "dateTime",
        yField: "temperature",
      });

      line.render();
    },
  },
};
</script>
<style scoped>
</style>